<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="content">
            <h:form rendered="#{loginBacking.createSystemUser}">

                <p:panel header="Personal Details">

                    <h:panelGrid columns="3" columnClasses="label, value" styleClass="grid">

                        <h:outputLabel value="Username" for="name" />
                        <p:inputText id="name" value="#{systemUserEntityController.selected.name}" title="#{bundle.CreateSystemUserEntityTitle_name}" required="true" requiredMessage="UserName is missing" 
                                     validator ="#{systemUserEntityController.validateUserName}">
                        </p:inputText>
                        <h:message styleClass="errorMsg" for= "name"/>

                        <h:outputLabel value="#{bundle.CreateSystemUserEntityLabel_title}" for="title" />
                        <h:selectOneMenu id="title" value="#{systemUserEntityController.selected.title}" title="#{bundle.CreateSystemUserEntityTitle_title}">
                            <f:selectItems value="#{systemUserEntityController.userTitles}" />
                        </h:selectOneMenu>
                        <h:message styleClass="errorMsg" for="title" />

                        <h:outputLabel value="#{bundle.CreateSystemUserEntityLabel_firstName}" for="firstName" />
                        <p:inputText id="firstName" value="#{systemUserEntityController.selected.firstName}" title="#{bundle.CreateSystemUserEntityTitle_firstName}" required="true" requiredMessage="First name is missing"/>
                        <h:message styleClass="errorMsg" for= "firstName"/>


                        <h:outputLabel value="#{bundle.CreateSystemUserEntityLabel_lastName}" for="lastName" />
                        <p:inputText id="lastName" value="#{systemUserEntityController.selected.lastName}" title="#{bundle.CreateSystemUserEntityTitle_lastName}" required="true" requiredMessage="Last name is missing" />
                        <h:message styleClass="errorMsg" for= "lastName"/>

                        <h:outputLabel value="#{bundle.CreateSystemUserEntityLabel_department}" for="department" />
                        <h:selectOneMenu id="department" value="#{systemUserEntityController.selected.department}" title="#{bundle.CreateSystemUserEntityTitle_department}">
                            <f:selectItems value="#{departmentEntityController.itemsAvailableSelectOne}"/>
                            <f:validator validatorId="macTeam.DepartmentSelectOneMenuValidator" />
                        </h:selectOneMenu>
                        <h:message styleClass="errorMsg" for= "department"/>

                    </h:panelGrid>
                </p:panel>
                <br />
                <p:panel header="Contact Information">
                    <h:panelGrid columns="3" columnClasses="label, value">
                        <h:outputLabel value="#{bundle.CreateContactEntityLabel_contactNumber}" for="contactNumber" />
                        <p:inputText id="contactNumber" value="#{systemUserEntityController.selected.contact.contactNumber}" title="#{bundle.CreateContactEntityTitle_contactNumber}" required="true" requiredMessage="Contact Number is missing" >
                            <f:validator validatorId="macTeam.ContactNumberValidator" />
                        </p:inputText>
                        <h:message styleClass="errorMsg" for= "contactNumber"/>

                        <h:outputLabel value="#{bundle.CreateContactEntityLabel_email}" for="email" />
                        <p:inputText id="email" value="#{systemUserEntityController.selected.contact.email}" title="#{bundle.CreateContactEntityTitle_email}" required="true" requiredMessage="Email is missing" validator ="#{contactEntityController.validateEmail}">
                            <f:validator validatorId="macTeam.EmailValidator" />
                        </p:inputText>
                        <h:message styleClass="errorMsg" for= "email" />
                    </h:panelGrid>
                </p:panel>

                <br />
                <h:commandButton value="Continue" action="#{systemUserEntityController.confirm}" />
                <h:commandButton action="#{systemUserEntityController.prepareCreate}" value="Reset">
                    <f:param name="skipvalidation" value="1" />
                </h:commandButton>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
